import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
       
        String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        String num = "22233344455566677778889999";
        HashMap<Character, Character> mp = new HashMap<>();
        char[] alphaArr = alpha.toCharArray();
        char[] numArr = num.toCharArray();
        for(int i = 0; i < alphaArr.length; ++i)
        {
            mp.put(alphaArr[i], numArr[i]);
        }
        TreeSet<String> set = new TreeSet<>();
        while(sc.hasNextInt()){
            set.clear();
             int line=Integer.parseInt(sc.nextLine());
            int n=line;
            for(int i=0;i<n;i++){
                String lin=null;
                String str=sc.nextLine();
                StringBuilder sb = new StringBuilder();
                char[] arr=str.toCharArray();
                for(char ch : arr)
                {
                    if(isDigit(ch))
                    sb.append(ch);
                    else if(isUpper(ch))
                    sb.append(mp.get(ch));
                }
                lin = sb.substring(0, 3) + "-" + sb.substring(3);
                //保存结果
                set.add(lin);
            }
            for(String str : set)
            System.out.println(str);
            //每组数据用空行隔开
            System.out.println();
            
        }
    }
    public static boolean isDigit(char ch)
    {
        return '0' <= ch && ch <= '9';
    } 
    public static boolean isUpper(char ch)
    {
        return 'A' <= ch && ch <= 'Z';
    }
}